// import store from '@/store'
import request from '../utils/request'

const userChannelAPI = () => request({
  method: 'GET',
  url: '/v1_0/user/channels'
  // headers: {
  //   Authorization: 'Bearer ' + store.state.token
  // }
})

// 获取内容的列表 把当前系统时间戳做一个默认值
// 数字类型转字符串，可拼接+‘’
const getArticleListAPI = ({ channelId, timestamp = Date.now() + ' ' }) => {
  return request({
    method: 'GET',
    url: '/v1_0/articles',
    params: {
      channel_id: channelId,
      timestamp
    }
  })
}
// 定义删除不感兴趣的接口
const articleDislikeAPI = ({ artId }) => {
  return request({
    method: 'POST',
    url: '/v1_0/article/dislikes',
    // headers: {
    //   Authorization: `Bearer ${store.state.token}`
    // },
    data: {
      target: artId
    }
  })
}

// 举报接口
const articleReportsAPI = ({ artId, type, remark }) => {
  return request({
    method: 'POST',
    url: '/v1_0/article/reports',
    // headers: {
    //   Authorization: `Bearer ${store.state.token}`
    // },
    data: {
      target: artId,
      type,
      remark: type === '0' ? remark : remark || null

    }
  })
}

// 定义接口，获取全部的数据
const gerAllChannelListAPI = () => {
  return request({
    method: 'GET',
    url: '/v1_0/channels'
  })
}

// 首页修改用户选择的频道
const updateUserChannleList = ({ channels }) => {
  return request({
    method: 'GET',
    url: '/v1_0/user/channels',
    data: {
      channels

    }
  })
}
export {
  userChannelAPI,
  getArticleListAPI,
  articleDislikeAPI,
  articleReportsAPI,
  gerAllChannelListAPI,
  updateUserChannleList
}
